<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
    <title>Coverage Report :: LevelFactory</title>
    <style type="text/css">
        @import "../../.css/coverage.css";
    </style>
</head>

<body>
<div class="header"></div>

<div class="content">
    <div class="breadCrumbs">
        [ <a href="../../index.html">all classes</a> ]
        [ <a href="../index.html">nl.tudelft.jpacman.level</a> ]
    </div>

    <h1>Coverage Summary for Class: LevelFactory (nl.tudelft.jpacman.level)</h1>

    <table class="coverageStats">

        <tr>
            <th class="name">Class</th>
            <th class="coverageStat
">
                Method, %
            </th>
            <th class="coverageStat
">
                Line, %
            </th>
        </tr>
        <tr>
            <td class="name">LevelFactory</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 4)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 17)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name">LevelFactory$MockitoMock$1070763866</td>
        </tr>
        <tr>
            <td class="name">LevelFactory$MockitoMock$1070763866$auxiliary$1teBwrmw</td>
        </tr>
        <tr>
            <td class="name">LevelFactory$MockitoMock$1070763866$auxiliary$6bRhzaGc</td>
        </tr>
        <tr>
            <td class="name">LevelFactory$MockitoMock$1070763866$auxiliary$AtmVFZgB</td>
        </tr>
        <tr>
            <td class="name">LevelFactory$MockitoMock$1070763866$auxiliary$mI4U9ag3</td>
        </tr>
        <tr>
            <td class="name">LevelFactory$MockitoMock$1070763866$auxiliary$USOAkjWC</td>
        </tr>
        <tr>
            <td class="name">LevelFactory$RandomGhost</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 2)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 3)
  </span>
            </td>
        </tr>
        <tr>
            <td class="name"><strong>total</strong></td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 6)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 20)
  </span>
            </td>
        </tr>
    </table>

    <br/>
    <br/>


    <div class="sourceCode"><i>1</i>&nbsp;package nl.tudelft.jpacman.level;
        <i>2</i>&nbsp;
        <i>3</i>&nbsp;import java.util.List;
        <i>4</i>&nbsp;import java.util.Map;
        <i>5</i>&nbsp;import java.util.Optional;
        <i>6</i>&nbsp;
        <i>7</i>&nbsp;import nl.tudelft.jpacman.board.Board;
        <i>8</i>&nbsp;import nl.tudelft.jpacman.board.Direction;
        <i>9</i>&nbsp;import nl.tudelft.jpacman.board.Square;
        <i>10</i>&nbsp;import nl.tudelft.jpacman.npc.Ghost;
        <i>11</i>&nbsp;import nl.tudelft.jpacman.npc.ghost.GhostColor;
        <i>12</i>&nbsp;import nl.tudelft.jpacman.npc.ghost.GhostFactory;
        <i>13</i>&nbsp;import nl.tudelft.jpacman.points.PointCalculator;
        <i>14</i>&nbsp;import nl.tudelft.jpacman.sprite.PacManSprites;
        <i>15</i>&nbsp;import nl.tudelft.jpacman.sprite.Sprite;
        <i>16</i>&nbsp;
        <i>17</i>&nbsp;/**
        <i>18</i>&nbsp; * Factory that creates levels and units.
        <i>19</i>&nbsp; *
        <i>20</i>&nbsp; * @author Jeroen Roosen
        <i>21</i>&nbsp; */
        <i>22</i>&nbsp;public class LevelFactory {
        <i>23</i>&nbsp;
        <i>24</i>&nbsp; private static final int GHOSTS = 4;
        <i>25</i>&nbsp; private static final int BLINKY = 0;
        <i>26</i>&nbsp; private static final int INKY = 1;
        <i>27</i>&nbsp; private static final int PINKY = 2;
        <i>28</i>&nbsp; private static final int CLYDE = 3;
        <i>29</i>&nbsp;
        <i>30</i>&nbsp; /**
        <i>31</i>&nbsp; * The default value of a pellet.
        <i>32</i>&nbsp; */
        <i>33</i>&nbsp; private static final int PELLET_VALUE = 10;
        <i>34</i>&nbsp;
        <i>35</i>&nbsp; /**
        <i>36</i>&nbsp; * The sprite store that provides sprites for units.
        <i>37</i>&nbsp; */
        <i>38</i>&nbsp; private final PacManSprites sprites;
        <i>39</i>&nbsp;
        <i>40</i>&nbsp; /**
        <i>41</i>&nbsp; * Used to cycle through the various ghost types.
        <i>42</i>&nbsp; */
        <i>43</i>&nbsp; private int ghostIndex;
        <i>44</i>&nbsp;
        <i>45</i>&nbsp; /**
        <i>46</i>&nbsp; * The factory providing ghosts.
        <i>47</i>&nbsp; */
        <i>48</i>&nbsp; private final GhostFactory ghostFact;
        <i>49</i>&nbsp;
        <i>50</i>&nbsp; /**
        <i>51</i>&nbsp; * The way to calculate points upon collisions.
        <i>52</i>&nbsp; */
        <i>53</i>&nbsp; private final PointCalculator pointCalculator;
        <i>54</i>&nbsp;
        <i>55</i>&nbsp; /**
        <i>56</i>&nbsp; * Creates a new level factory.
        <i>57</i>&nbsp; *
        <i>58</i>&nbsp; * @param spriteStore
        <i>59</i>&nbsp; * The sprite store providing the sprites for units.
        <i>60</i>&nbsp; * @param ghostFactory
        <i>61</i>&nbsp; * The factory providing ghosts.
        <i>62</i>&nbsp; * @param pointCalculator
        <i>63</i>&nbsp; * The algorithm to calculate the points.
        <i>64</i>&nbsp; */
        <i>65</i>&nbsp; public LevelFactory(PacManSprites spriteStore,
        <i>66</i>&nbsp; GhostFactory ghostFactory,
        <b class="nc"><i>67</i>&nbsp; PointCalculator pointCalculator) {</b>
        <b class="nc"><i>68</i>&nbsp; this.sprites = spriteStore;</b>
        <b class="nc"><i>69</i>&nbsp; this.ghostIndex = -1;</b>
        <b class="nc"><i>70</i>&nbsp; this.ghostFact = ghostFactory;</b>
        <b class="nc"><i>71</i>&nbsp; this.pointCalculator = pointCalculator;</b>
        <b class="nc"><i>72</i>&nbsp; }</b>
        <i>73</i>&nbsp;
        <i>74</i>&nbsp; /**
        <i>75</i>&nbsp; * Creates a new level from the provided data.
        <i>76</i>&nbsp; *
        <i>77</i>&nbsp; * @param board
        <i>78</i>&nbsp; * The board with all ghosts and pellets occupying their squares.
        <i>79</i>&nbsp; * @param ghosts
        <i>80</i>&nbsp; * A list of all ghosts on the board.
        <i>81</i>&nbsp; * @param startPositions
        <i>82</i>&nbsp; * A list of squares from which players may start the game.
        <i>83</i>&nbsp; * @return A new level for the board.
        <i>84</i>&nbsp; */
        <i>85</i>&nbsp; public Level createLevel(Board board, List&lt;Ghost&gt; ghosts, List&lt;Square&gt;
        startPositions) {
        <i>86</i>&nbsp;
        <i>87</i>&nbsp; // We&#39;ll adopt the simple collision map for now.
        <b class="nc"><i>88</i>&nbsp; CollisionMap collisionMap = new PlayerCollisions(pointCalculator);</b>
        <i>89</i>&nbsp;
        <b class="nc"><i>90</i>&nbsp; return new Level(board, ghosts, startPositions, collisionMap);</b>
        <i>91</i>&nbsp; }
        <i>92</i>&nbsp;
        <i>93</i>&nbsp; /**
        <i>94</i>&nbsp; * Creates a new ghost.
        <i>95</i>&nbsp; *
        <i>96</i>&nbsp; * @return The new ghost.
        <i>97</i>&nbsp; */
        <i>98</i>&nbsp; Ghost createGhost() {
        <b class="nc"><i>99</i>&nbsp; ghostIndex++;</b>
        <b class="nc"><i>100</i>&nbsp; ghostIndex %= GHOSTS;</b>
        <b class="nc"><i>101</i>&nbsp; switch (ghostIndex) {</b>
        <i>102</i>&nbsp; case BLINKY:
        <b class="nc"><i>103</i>&nbsp; return ghostFact.createBlinky();</b>
        <i>104</i>&nbsp; case INKY:
        <b class="nc"><i>105</i>&nbsp; return ghostFact.createInky();</b>
        <i>106</i>&nbsp; case PINKY:
        <b class="nc"><i>107</i>&nbsp; return ghostFact.createPinky();</b>
        <i>108</i>&nbsp; case CLYDE:
        <b class="nc"><i>109</i>&nbsp; return ghostFact.createClyde();</b>
        <i>110</i>&nbsp; default:
        <b class="nc"><i>111</i>&nbsp; return new RandomGhost(sprites.getGhostSprite(GhostColor.RED));</b>
        <i>112</i>&nbsp; }
        <i>113</i>&nbsp; }
        <i>114</i>&nbsp;
        <i>115</i>&nbsp; /**
        <i>116</i>&nbsp; * Creates a new pellet.
        <i>117</i>&nbsp; *
        <i>118</i>&nbsp; * @return The new pellet.
        <i>119</i>&nbsp; */
        <i>120</i>&nbsp; public Pellet createPellet() {
        <b class="nc"><i>121</i>&nbsp; return new Pellet(PELLET_VALUE, sprites.getPelletSprite());</b>
        <i>122</i>&nbsp; }
        <i>123</i>&nbsp;
        <i>124</i>&nbsp; /**
        <i>125</i>&nbsp; * Implementation of an NPC that wanders around randomly.
        <i>126</i>&nbsp; *
        <i>127</i>&nbsp; * @author Jeroen Roosen
        <i>128</i>&nbsp; */
        <i>129</i>&nbsp; private static final class RandomGhost extends Ghost {
        <i>130</i>&nbsp;
        <i>131</i>&nbsp; /**
        <i>132</i>&nbsp; * The suggested delay between moves.
        <i>133</i>&nbsp; */
        <i>134</i>&nbsp; private static final long DELAY = 175L;
        <i>135</i>&nbsp;
        <i>136</i>&nbsp; /**
        <i>137</i>&nbsp; * Creates a new random ghost.
        <i>138</i>&nbsp; *
        <i>139</i>&nbsp; * @param ghostSprite
        <i>140</i>&nbsp; * The sprite for the ghost.
        <i>141</i>&nbsp; */
        <i>142</i>&nbsp; RandomGhost(Map&lt;Direction, Sprite&gt; ghostSprite) {
        <b class="nc"><i>143</i>&nbsp; super(ghostSprite, (int) DELAY, 0);</b>
        <b class="nc"><i>144</i>&nbsp; }</b>
        <i>145</i>&nbsp;
        <i>146</i>&nbsp; @Override
        <i>147</i>&nbsp; public Optional&lt;Direction&gt; nextAiMove() {
        <b class="nc"><i>148</i>&nbsp; return Optional.empty();</b>
        <i>149</i>&nbsp; }
        <i>150</i>&nbsp; }
        <i>151</i>&nbsp;}
    </div>
</div>

<div class="footer">

    <div style="float:right;">generated on 2023-04-25 16:45</div>
</div>
</body>
</html>
